package cn.laike.modules.dev.service.impl;

import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import cn.laike.common.utils.PageUtils;
import cn.laike.common.utils.Query;

import cn.laike.modules.dev.dao.BannerDao;
import cn.laike.modules.dev.entity.BannerEntity;
import cn.laike.modules.dev.service.BannerService;
import cn.laike.modules.sys.shiro.ShiroUtils;


@Service("bannerService")
public class BannerServiceImpl extends ServiceImpl<BannerDao, BannerEntity> implements BannerService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
    	Integer hotelId = ShiroUtils.getHotelId();
        Page<BannerEntity> page = this.selectPage(
                new Query<BannerEntity>(params).getPage(),
                new EntityWrapper<BannerEntity>()
                .eq(ShiroUtils.isAdmin(),"uid", ShiroUtils.getUserId())
                .eq((hotelId != null && hotelId > 0), "hotel_id", hotelId)
                .orderBy("sort", false)
        );

        return new PageUtils(page);
    }

	@Override
	public List queryBannerList(Long uid) {
		return baseMapper.queryBannerList(uid);
	}

}
